////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBot\RhsTreeNode.h
///
/// @brief  Declares the CollabRC::Bot::AI::RhsTreeNode class
////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#include "OperationTreeNode.h"

namespace CollabRC
{
    namespace Bot
    {
        namespace AI
        {
            /**
             * @brief Implementation of an OperationTreeNode which 
             * passes through the right hand side of the operation,
             * discarding the left hand side. 
             *
             * When possible, this operation will optimize out this operation,
             * replacing itself with a copy of the right hand branch.
             * @version $Id$
             * @author Matthew P. Del Buono
             */
            class RhsTreeNode : public OperationTreeNode
            {
            private:
                class Factory : public OperationTreeNodeFactory
                {
                public:
                    Factory();
                    ComputationalTreeNode* Instantiate(const ComputationalTreeNode& lhs, const ComputationalTreeNode& rhs) const;
                };

                static Factory factory;
                const ComputationalTreeNode* const m_branch;

                /// Blocks the assignment operator from being used
                const RhsTreeNode& operator=(const RhsTreeNode&);
            public:
                RhsTreeNode(const ComputationalTreeNode& lhs, const ComputationalTreeNode& rhs);
                RhsTreeNode(const OperationTreeNode& copy);
                virtual ~RhsTreeNode(void);

                virtual float PerformOperation(float lhs, float rhs) const;
                virtual ComputationalTreeNode* Clone() const;
                virtual void Accept(ComputationalTreeNodeVisitor& visitor);
            };
        }
    }
}
